****************************************************************
****************************************************************
*REPLICATION FILE **********************************************
*"Buying Evidence: Policy Research as a Presidential Commodity"*
*Journal of Politics *******************************************
*Rachel Augustine Potter ***************************************
*rapotter@virginia.edu *****************************************
*December 2023 **************************************************
****************************************************************
****************************************************************

**This .do file replicates Figure B-2 in the Appendix 

*Before beginning, change the working directory to your local directory and run the file "compiling.do"

***Figure B-2 Scatterplot 
*"Policy Research Spending & Presidential Agenda, by Agency"

keep if  restricted ==1 & amount > 1000 

*collapse (sum) pos_oblig (firstnm)   PA_majortopic PA_majorname acr PA_subtopicname PA_subtopic  , by(Agency) 
collapse (sum) pos_oblig (firstnm) acr PA_subtopicname PA_subtopic  , by(Agency) 

joinby PA_subtopic using "total_subtopics.dta", unmatched(master)

replace pos_oblig = pos_oblig/1000000

gen jitter = rnormal(0, .25)

gen subtopic_anymention_jitter = subtopic_anymention + jitter

replace acr = "EPA" if Agency ==185
replace acr = "DOE" if Agency ==264
gen acrkeep = 1 if  acr == "NOAA" | acr== "USAF" | acr == "ARMY" | acr == "NIH" |acr == "FDA" | acr == "ED" |acr == "SSA" | acr == "CDC" | acr == "FAA" | acr == "IRS" | acr == "CDC" | acr == "CMS" | acr == "FCC" | acr == "OPM" | acr == "NSF" | acr == "FS" |acr == "EBSA" | acr == "DOE" |acr =="EPA" & Agency == 185
gen acr2 = acr if acrkeep ==1
twoway (scatter  pos_oblig subtopic_anymention_jitter , msize(vsmall) ylab(,nogrid) yline(0) graphregion(color(white)) jitter(45) mlabp(noon) xtitle("Mean Presidential Agenda Score") mlabel(acr2) ytitle("Policy Research Spending (total)") yscale(range(0 4000)) ylabel(1000 "$1B"2000 "$2B" 3000 "$3B" 4000 "$4B" , angle(horizontal) ) mcol(black)) (lfit pos_oblig subtopic_anymention_jitter ),  name(scatter, replace) legend(off)
